package model.resource;

import java.util.Hashtable;
import java.util.Map;

import model.entity.BasicEntity;
import model.entity.Entity;
import model.entity.Mountable;
import model.entity.stats.StatType;

/**
 * 
 *
 * This class is used to handle something like an avatar
 * being mounted on an NPC.
 *
 */

public class AvatarMount{


	private static AvatarMount instance = null;
	private Map<BasicEntity, Mountable> mountMap;

	private AvatarMount() {
		mountMap = new Hashtable<BasicEntity, Mountable>();
	}

	public static AvatarMount getInstance() {
		if (instance != null) {
			return instance;
		}
		return instance = new AvatarMount();
	}

	public void add(Entity e, Mountable m){
		mountMap.put(e, m);
	}

	public void remove(Entity e){
		mountMap.remove(e);
	}

	public boolean isMounted(BasicEntity e){
		if(mountMap.get(e) == null)
			return false;
		return true;
	}

	public Mountable getMount(BasicEntity e){
		return mountMap.get(e);
	}

	public double getMountableSpeed(BasicEntity e){
		Mountable m = mountMap.get(e);
		double movementSpeed = m.getStatVal(StatType.MOVEMENTSPEED);
		return movementSpeed;
	}


}


